﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PRE
{
    using System.IO;

    public partial class FrmExplorer : Form
    {
        public FrmExplorer()
        {
            InitializeComponent();
        }

        private void Explorer_Load(object sender, EventArgs e)
        {
            try
            {
                //var bll = new BLL.RoomBLL();
                //var dtb = bll.Select();

                lsvMain.BeginUpdate();                
                lsvMain.LargeImageList = imageList1;
                DriveInfo[] allDrives = DriveInfo.GetDrives();

                
                foreach (DriveInfo dr in allDrives)
                {
                    ListViewItem listItem = new ListViewItem(dr.Name);

                    switch (dr.DriveType)
                    {
                        case DriveType.Fixed:
                            listItem.ImageIndex = 0;
                            break;
                        case DriveType.Removable:
                            listItem.ImageIndex = 1;
                            break;
                        case DriveType.CDRom:
                            listItem.ImageIndex = 2;
                            break;
                        default:
                            listItem.ImageIndex = 3;
                            break;

                    }

                    
                    lsvMain.Items.Add(listItem);
                }
                
                lsvMain.EndUpdate();
            }
            catch { return; }
        }

        private void lsvMain_MouseDoubleClick(object sender, MouseEventArgs e)
        {

            if (e.Button == MouseButtons.Left)
            {
                ListViewItem listItem = (ListViewItem)sender;
                DirectoryInfo di = new DirectoryInfo(listItem.Name);
                var directories = di.GetFiles("*", SearchOption.AllDirectories);

                foreach (FileInfo d in directories)
                {
                    //Add files to a list so that later they can be compared to see if each file
                    // needs to be copid or not
                }
            }
        }
    }
}
